package net.siufung.security.service.defaults;

import lombok.AllArgsConstructor;
import net.siufung.security.api.service.ICurrentUserPasswdService;
import net.siufung.security.base.service.ICurrentClientService;

/**
 * @author 陈建峰
 * @since 2022/3/4 1:25 下午
 */
@AllArgsConstructor
public class DefaultCurrentUserPasswdServiceImpl implements ICurrentUserPasswdService {

    private final ICurrentClientService currentClientService;

    @Override
    public String encode(String password) {
        return currentClientService.getAuthorizationPasswordEncoder()
                .encode(password);
    }

    @Override
    public boolean matches(String rawPassword, String encodedPassword) {
        return currentClientService.getAuthorizationPasswordEncoder()
                .matches(rawPassword, encodedPassword);
    }
}
